package br.com.felix.dbm.util.io;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import br.com.felix.dbm.sql.SQLBuilder;

public class SQLFileManager {

	
	public void save(SQLBuilder sqlb, File targetFile) throws IOException{
		if(targetFile.exists()){
			targetFile.delete();
		}
		if(targetFile.createNewFile()){
			String sql = sqlb.toString();
			FileWriter fw = new FileWriter(targetFile);
			fw.write(sql);
			fw.close();
		}
		else{
			throw new IOException("Could not create new file.");
		}
	}
}
